#include "link_list.h"

Elenemt_data Stu_data[50] = 
{
 { .name = "刘备" , .sex = "男" , .sco = 60 , .age = 18 , .id = 1  },
 { .name = "关羽" , .sex = "男" , .sco = 60 , .age = 18 , .id = 2  },
 { .name = "张飞" , .sex = "女" , .sco = 60 , .age = 18 , .id = 3  },
 { .name = "诸葛" , .sex = "男" , .sco = 60 , .age = 18 , .id = 4  },
 { .name = "赵云" , .sex = "男" , .sco = 60 , .age = 18 , .id = 5  },
 { .name = "马超" , .sex = "男" , .sco = 60 , .age = 18 , .id = 6  },
 { .name = "祝融" , .sex = "女" , .sco = 60 , .age = 18 , .id = 7  },
 { .name = "小乔" , .sex = "女" , .sco = 60 , .age = 18 , .id = 8  },
 { .name = "大乔" , .sex = "女" , .sco = 60 , .age = 18 , .id = 9  },
 { .name = "貂蝉" , .sex = "女" , .sco = 60 , .age = 18 , .id = 10  }
};

void test(void)
{
    Link_list * L = init_link_list();

    // 创建动态空间 给 结点
    for (size_t i = 0; i < 5; i++)
    {
        insert_node(L, Stu_data[i], i+1);
    }

    // 遍历
    printf("===========插入赋值==============\n");
    print_link_list(L);

    printf("=============删除==============\n");
    delete_node(L, 2);
    print_link_list(L);
    printf("=============查找==============\n");
    Node *find=find_node_id(L, 3);
    printf("姓名:%s 性别:%s 年龄:%d 成绩:%d 学号:%d\n",
            find->data.name , find->data.sex , find->data.age , 
            find->data.sco  , find->data.id 
            );
    printf("=============合并==============\n");
    Link_list * L1 = init_link_list();
    Link_list * L2 = init_link_list();
    for (size_t i = 0; i < 5; i++)
    {
        insert_node(L1, Stu_data[i], i+1);
    }
    for (size_t i = 0; i < 5; i++)
    {
        insert_node(L2, Stu_data[i], i+1);
    }
    print_link_list(merge_link_lists(L1, L2));

    free_link_list(&L);
}


int main(int argc, char const *argv[])
{
    test();
    return 0;
}


